package com.aidex.system.mapper;

import com.aidex.common.core.domain.entity.SysRole;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SysRoleMapper extends BaseMapper<SysRole> {

    @Select("select t.* from sys_role t left join sys_user_role ur on ur.role_id = t.id left join sys_user u on u.id = ur.user_id ${ew.customSqlSegment}")
    List<SysRole> selectListByUser(@Param("ew") QueryWrapper<SysRole> wrapper);

    @Select("select t.* from sys_role t left join sys_user_role ur on ur.role_id = t.id where ur.user_id = #{id}")
    List<SysRole> selectListByUserId(@Param("id") String userId);

    @Select("select max(a.sort) from sys_role a where del_flag = 0")
    Integer findMaxSort();
}
